﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Activities;
using System.Diagnostics;

namespace Wicresoft.Platform.Workflows.Mobile.Tasks
{
    public sealed class Complete : ITask
    {
        public void Execute(Wicresoft_Platform_Processes_Mobile wppMobile, ActivityContext context)
        {
            Debug.Assert(wppMobile != null, "wppMobile cannot be null");

            using (MobileEntities db = new MobileEntities(true))
            {
                var e = db.Wicresoft_Platform_Processes_Mobile.Single(p => p.Id == wppMobile.Id);

                e.AssignedTo = "Closed";
                e.CurrentState = ProcessState.Completed.ToString();
                e.LastModifiedTime = DateTime.Now;
                e.LastModifiedBy = "System";

                db.SaveChanges();
            }
        }
    }
}
